package com.prs.crm.action.cdxh;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.annotation.Clew;
import com.prs.crm.domain.cdxh.EarningSal;
import com.prs.crm.domain.cdxh.HrPerson;
import com.prs.crm.domain.cdxh.wages.MaterialWages;
import com.prs.crm.domain.cdxh.wages.MoldingWages;
import com.prs.crm.domain.cdxh.wages.PrintWages;
import com.prs.crm.service.cdxh.EarningSalService;
import com.prs.crm.service.cdxh.HrPersonService;
import com.prs.crm.service.cdxh.MaterialWagesService;
import com.prs.crm.service.cdxh.MoldingWagesService;
import com.prs.crm.service.cdxh.PrintWagesService;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2010-12-16 下午01:48:06 简单说明
 */

public class EarningSalAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private MaterialWagesService MaterialWagesService;

	private MoldingWagesService MoldingWagesService;

	private PrintWagesService PrintWagesService;

	private PaginationSupport pagination;

	private EarningSal earningSal;

	private HrPersonService hrPersonService;

	private EarningSalService earningSalService;

	private int stateNums = 0;

	private String oversNUms = "0.0";

	private int objextMapp = 1;
	/**
	 * 配料
	 * @return
	 */
	@Action("listMaterialWages")
	public String listMaterialWages() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				MaterialWages.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMaterialWagesService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	
	/**
	 * 成型
	 * @return
	 */
	@Action("listMoldingWages")
	public String listMoldingWages() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				MoldingWages.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMoldingWagesService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	
	/**
	 * 印刷
	 * @return
	 */
	@Action("listPrintWages")
	public String listPrintWages() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PrintWages.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getPrintWagesService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	
	@Action("listEarningSal")
	public String listEarningSal() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				EarningSal.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getEarningSalService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("EarningSalPerson")
	public String EarningSalPerson() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				HrPerson.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getHrPersonService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("editEarningSal")
	public String editEarningSal() {
		return SUCCESS;
	}

	@Clew(results = { "success", "none", "error" })
	@Action(value = "submitEarningSal", results = {
			@Result(name = "success", type = "redirect", location = "editEarningSal?oversNUms=${oversNUms}&stateNums=1"),
			@Result(name = "error", type = "redirect", location = "editEarningSal") })
	public String submitEarningSal() {
		String datess[] = earningSal.getCurrentDate().split("-");
		String alls = datess[1] + "/" + datess[0];
		oversNUms = this.getEarningSalService().getSal(earningSal.getHrName(),
				alls);
		this.setPrompt("请等待数据处理中....");
		return SUCCESS;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public EarningSal getEarningSal() {
		return earningSal;
	}

	public void setEarningSal(EarningSal earningSal) {
		this.earningSal = earningSal;
	}

	public EarningSalService getEarningSalService() {
		return earningSalService;
	}

	public void setEarningSalService(EarningSalService earningSalService) {
		this.earningSalService = earningSalService;
	}

	public int getStateNums() {
		return stateNums;
	}

	public void setStateNums(int stateNums) {
		this.stateNums = stateNums;
	}

	public HrPersonService getHrPersonService() {
		return hrPersonService;
	}

	public void setHrPersonService(HrPersonService hrPersonService) {
		this.hrPersonService = hrPersonService;
	}

	public String getOversNUms() {
		return oversNUms;
	}

	public void setOversNUms(String oversNUms) {
		this.oversNUms = oversNUms;
	}

	public int getObjextMapp() {
		return objextMapp;
	}

	public void setObjextMapp(int objextMapp) {
		this.objextMapp = objextMapp;
	}

	public MaterialWagesService getMaterialWagesService() {
		return MaterialWagesService;
	}

	public void setMaterialWagesService(
			MaterialWagesService materialWagesService) {
		MaterialWagesService = materialWagesService;
	}

	public MoldingWagesService getMoldingWagesService() {
		return MoldingWagesService;
	}

	public void setMoldingWagesService(MoldingWagesService moldingWagesService) {
		MoldingWagesService = moldingWagesService;
	}

	public PrintWagesService getPrintWagesService() {
		return PrintWagesService;
	}

	public void setPrintWagesService(PrintWagesService printWagesService) {
		PrintWagesService = printWagesService;
	}

}
